using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class VActSkillEffect : MonoBehaviour
{
    public VActProcessor mainProcessor;
    public VActProcessor collisionProcessor;
    public VActor curActor;

    public void LoadEffect(VActProcessor processor)
    {
        mainProcessor = processor;
        OnTEnterAction += Slash;
    }

    public void Slash(VActor actor)
    {
        actor.input.ForceDoAct("hit");
        mainProcessor.WriteSkillParam("Slash",actor.gameObject.name);
    }


    #region  Collision
    public Action<VActor> OnTEnterAction;
    public Action<VActor> OnTExitAction;
    private void OnTriggerEnter(Collider other)
    {
        if (other.TryGetComponent<VActor>(out var actor))
        {
            curActor = actor;
            collisionProcessor = other.GetComponent<VActProcessor>();
            OnTEnterAction?.Invoke(curActor);
        }
    }

    private void OnTriggerExit(Collider other)
    {
        OnTExitAction?.Invoke(curActor);
        curActor = null;
        collisionProcessor = null;
    }
    #endregion
}
